package demo1;

import java.util.Scanner;

class Login {
    private String name = "admin";
    private String password = "12345";

    public void loginInfo(String name, String password) throws UserNameErrorException,PasswordErrorException{
        if (!this.name.equals(name)) {
            throw new UserNameErrorException("用户名错误参数");
        }

        if (!this.password.equals(password)) {
            throw new PasswordErrorException("密码异常参数");
        }

        System.out.println("登陆成功！");
    }

    public static void main(String[] args) {

        try {
            Login login = new Login();
            login.loginInfo("dmin", "12345");
        }catch (UserNameErrorException e) {
            e.printStackTrace();
            System.out.println("用户名异常");
        }catch (PasswordErrorException e) {
            e.printStackTrace();
            System.out.println("密码异常");
        }
    }
}

public class Test {

    public static void func() {
        int[] arr = {1, 2, 3};
        System.out.println(arr[100]);
    }

    public static void main(String[] args) {
        func();
        System.out.println("其他");
    }

    public static void main2(String[] args) {
        int[] arr1 = {1, 2, 3, 7, 0, 0, 0};
        int[] arr2 = {4, 5, 6};


        int j = arr2.length-1; // 2
        int sum = arr1.length-1; // 6
        int i = sum - j - 1; // 3

        while (i>=0 && j>=0) {
            if (arr1[i] > arr2[j]) {
                arr1[sum] = arr1[i];
                sum--;
                i--;
            }else {
                arr1[sum] = arr2[j];
                sum--;
                j--;
            }
        }

        while (j >= 0) {
            arr1[sum] = arr2[j];
            sum--;
            j--;
        }

        for (int k = 0; k < arr1.length; k++) {
            System.out.print(arr1[k]);
        }
    }

    public static String func(String str) {
        char[] arr1 = new char[127];
        char[] arr2 = str.toCharArray();
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if (arr1[arr2[i]] == 0) {
                arr1[arr2[i]] = 1;
                ret.append(arr2[i]);
            }
        }
        return ret.toString();
    }

    public static String func2(String str) {
        char[] arr = new char[127];
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            if (arr[ch] == 0) {
                arr[ch] = 1;
                ret.append(ch);
            }
        }
        return ret.toString();
    }

    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextLine()) {
            String str = scanner.nextLine();
            String ret = func2(str);
            System.out.println(ret);
        }
    }
}
